package com.chat.system.utils;

import com.chat.system.entity.po.ChatUserRelationship;
import org.springframework.security.core.context.SecurityContextHolder;

public class UserUtil {

    public static String getCurrentUserName(){
        return SecurityContextHolder.getContext().getAuthentication().getName();
    }

    public static String getCurrentFriendName(String currentUserName, ChatUserRelationship relationship) {
        String friendName;
        if (currentUserName.equals(relationship.getUserName())) {
            friendName = relationship.getFriendName();
        }else {
            friendName = relationship.getUserName();
        }
        return friendName;
    }
}
